home *** CD-ROM | disk | FTP | other *** search
- /*****
- * FILE: CMacLockPane.c
- * Programmer: Mark Bykerk Kauffman
- * Copyright © 1990.
- * Date: 1/91
- * Purpose:
- * Pane methods for MacLock.
- * PARENTCLASS = CStarterPane
- *
- *****/
-
- #include <string.h>
- #include "CMacLockPane.h"
- #include "CPassword.h"
-
- /* Global Variables used by objects of this class. */
- /* commands */
- #define LockIt 5000
-
- /* resource IDs */
- #define ButtonID1 2047
- #define openLockRsrc 2049
- #define closedLockRsrc 2050
-
- /* The single password object global to the application. */
- extern CPassword *gThePassword;
-
- /* METHOD IMPLEMENTATIONS */
-
- /*****
- * IMacLockPane
- *
- * MacLockPane's initialization method.
- * Setup the lock's location for the Draw method, get the icons from the
- * resource table, initialize the window the lock is displayed in,
- * and create a button object.
- *
- *****/
- void CMacLockPane::IMacLockPane(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing)
- {
- SetRect(&LockLocation,10,10,74,74);
-
- openLockIcon = GetIcon(openLockRsrc);
- closedLockIcon = GetIcon(closedLockRsrc);
- displayedIcon = openLockIcon;
- CPanorama::IPanorama(anEnclosure, aSupervisor, aWidth, aHeight,
- aHEncl, aVEncl, aHSizing, aVSizing);
- LockButton = new(CButton);
- LockButton->IButton(ButtonID1, this, this);
- LockButton->SetClickCmd(LockIt);
- SetWantsClicks(TRUE);
-
- }
-
- /*****
- * Dispose
- *
- * MacLockPane's dispose method.
- * Get rid of the lock button object then call the inherited dispose
- * method.
- *
- *****/
- void CMacLockPane::Dispose(void)
-
- {
- LockButton->Dispose();
- inherited::Dispose();
- }
-
- /*****
- * DoCommand
- *
- * MacLockPane's DoCommand method.
- * When the lock button is pressed, display the closed lock icon and
- * wait for the password. After the password is entered, display
- * the open lock icon.
- *
- *****/
- void CMacLockPane::DoCommand(long theCommand)
-
- {
- Rect Location;
- char answer[255]="\0";
-
-
- switch (theCommand)
- {
- case LockIt: this->Prepare();
- displayedIcon = closedLockIcon;
- SysBeep(20);
- Draw(&frame); /* frame is an instance variable
- defined in CPane.
- */
- gThePassword->WaitForPassword();
- displayedIcon = openLockIcon;
- Draw(&frame);
- break;
-
- default: inherited::DoCommand(theCommand);
- break;
- }
- }
-
- /***
- * Draw
- *
- * MacLockPane's Draw method.
- *
- *
- ***/
- void CMacLockPane::Draw(Rect *area)
-
- {
- Rect Location;
-
- /* draw your stuff */
- Location = this->LockLocation;
- PlotIcon(&Location,displayedIcon);
- }
-
-
-